<!--
 * @description  : 案件-简易案件-当场行政处罚决定书
 * @descriptionDetail: 案件-简易案件-当场行政处罚决定书
 * @copyright    : 浙江烟草
 * @author       : sy
 * @create       : 2022-09-05 15:43:11
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
      <view class="white-color" @click="printOrDown(state.canEdit)">
        {{ state.canEdit?'预览':'打印' }}
      </view>
    </theme-navbar>
    <!-- #endif -->
		<!-- #ifdef H5-WECHAT || H5-EMP -->
		<fab-button :content="state.canEdit?fContent:fContents" @fabtrigger="fabtrigger" />
		<!-- #endif -->
    <view class="top-title-content">
      <view class="main-title">
        {{ caseData.orgShortname }}
      </view>
      <view class="sub-title">
        当场行政处罚决定书
      </view>
      <view class="content-detail">
        <u-input
          placeholder="请输入"
          :disabled="!state.canEdit"
          input-align="center"
          v-model="caseData.fullDocNo"
        />
      </view>
    </view>
    <u-gap height="20" bg-color="#f2f2f2"></u-gap>
    <view class="main-content">
      <u-form class="form-content" :model="caseData" :error-type="errorType" :rules="rules" ref="uForm">
        <u-form-item
          label="案发时间"
          :required="isRequired"
          prop="caseData"
          right-icon="arrow-right"
          :label-position="labelPosition"
          ref="changeRefS"
        >
          <u-input
            placeholder="请选择开始时间"
            :disabled="true"
            :clearable="false"
						:custom-style="pointerStyle"
            v-model="caseData.caseDate"
            @click="()=>{if(state.canEdit) isShowCaseDate = true}"
          />
        </u-form-item>
        <u-form-item label="案发地点" prop="caseAddr" :label-position="labelPosition" :required="isRequired">
          <u-input
            placeholder="请输入案发地点"
            :disabled="!state.canEdit"
            v-model="caseData.caseAddr"
            maxlength="100"
          />
        </u-form-item>
        <u-form-item label="当事人" prop="partyNames" :label-position="labelPosition" :required="isRequired" right-icon="arrow-right">
          <u-input
            placeholder="请选择当事人"
            :disabled="true"
						:custom-style="pointerStyle"
            v-model="partyNames"
            @click="()=>{if(state.canEdit) partySelectShow = true}"
          />
        </u-form-item>
        <u-form-item
          label="案由"
          :label-position="labelPosition"
          :required="true"
          prop="caseProperty"
          ref="caseChangeRef"
        >
          <u-input
            type="textarea"
            height="35"
            :auto-height="true"
            placeholder=""
            :disabled="true"
						:custom-style="pointerStyle"
            v-model="caseData.caseProperty"
          />
        </u-form-item>
        <u-form-item label="违反条例" :label-position="labelPosition" :required="true" prop="legalItem">
          <u-input
            placeholder="请输入违反条例"
            type="textarea"
            height="35"
            :auto-height="true"
            :disabled="!state.canEdit"
            v-model="caseData.legalItem"
          />
        </u-form-item>
        <u-form-item label="处罚条例" :label-position="labelPosition" :required="true" prop="punishArgument">
          <u-input
            placeholder="请输入处罚条例"
            type="textarea"
            height="35"
            :auto-height="true"
            :disabled="!state.canEdit"
            v-model="caseData.punishArgument"
          />
        </u-form-item>
        <u-form-item
          label="处罚形式"
          :label-width="labelWidth"
          right-icon="arrow-right"
          prop="punishItem"
          :required="true"
          ref="punishRefs"
        >
          <u-select
            :list="PUNISH_DATA"
            mode="single-column"
            v-model="importLicShow"
            @confirm="selectConfirm('punishItem','punishName',$event)"
          ></u-select>
          <u-input
            :clearable="false"
            :disabled="true"
            placeholder="请选择"
            input-align="right"
						:custom-style="pointerStyle"
            v-model="caseData.punishName"
            @click="state.canEdit&&(importLicShow = true)"
          />
        </u-form-item>
        <!-- 案值 -->
        <u-form-item
          label="案值(元)"
          label-position="top"
          label-width="auto"
          :required="true"
          prop="localCaseTotalVal"
          v-if="caseData.punishItem == LOCAL_PUNISH.FINE"
        >
          <u-input
            :disabled="!state.canEdit"
            :clearable="false"
            v-model="caseData.localCaseTotalVal"
            @input="changeUpperNumber"
          />
        </u-form-item>
        <!-- 处罚比例 -->
        <u-form-item
          label="处罚比例(%)"
          label-position="top"
          label-width="auto"
          :required="true"
          prop="rate"
          v-if="caseData.punishItem == LOCAL_PUNISH.FINE"
        >
          <u-input
            :disabled="!state.canEdit"
            :clearable="false"
            v-model="caseData.rate"
            @input="changeUpperNumber"
          />
        </u-form-item>
        <!-- 罚款显示页面 -->
        <u-form-item
          label="罚款人民币"
          :label-position="labelPosition"
          :required="true"
          prop="upperMoney"
          v-if="caseData.punishItem == LOCAL_PUNISH.FINE"
        >
          <view style="width:100%">
            <view class="input-text">
              ￥：
              <u-input
                :disabled="true"
                :clearable="false"
                placeholder=""
								:custom-style="pointerStyle"
                v-model="caseData.punishAmt"
              />
            </view>
            <view class="input-text ">
              大写：
              <u-input :disabled="true" placeholder="" v-model="caseData.upperMoney" />
            </view>
          </view>
        </u-form-item>
        <view v-if="caseData.punishItem == LOCAL_PUNISH.FINE">
          <u-form-item prop="payName" label="缴款方式" right-icon="arrow-right" :label-width="labelWidth">
            <u-select
              :list="payTypeList"
              mode="single-column"
              v-model="payShow"
              @confirm="selectConfirm('payStyle','payName',$event)"
            ></u-select>
            <u-input
              :clearable="false"
              :disabled="true"
							:custom-style="pointerStyle"
              placeholder="请选择"
              input-align="right"
              v-model="caseData.payName"
              @click="state.canEdit&&(payShow = true)"
            />
          </u-form-item>
          <view v-if="caseData.payStyle == LOCAL_PAY.OTHER">
            <u-form-item label="缴款银行" :label-position="labelPosition">
              <u-input placeholder="请输入缴款银行" :disabled="!state.canEdit" v-model="caseData.payAddress" />
            </u-form-item>
            <!-- <u-form-item label="账号" :label-position="labelPosition">
              <u-input placeholder="请输入账号" :disabled="!state.canEdit" v-model="caseData.bankNo" />
            </u-form-item>
            <u-form-item label="户名" :label-position="labelPosition">
              <u-input placeholder="请输入户名" :disabled="!state.canEdit" v-model="caseData.bankName" />
            </u-form-item> -->
          </view>
        </view>
        <u-form-item label="复议机关" :label-position="labelPosition">
          <u-input placeholder="请输入复议机关" :disabled="!state.canEdit" v-model="caseData.parentOrg" />
        </u-form-item>
        <u-form-item label="起诉法院" :label-position="labelPosition">
          <u-input placeholder="请输入起诉法院" :disabled="!state.canEdit" v-model="caseData.peopleCourt" />
        </u-form-item>
        <u-form-item
          label="执法人员(签名)"
          prop="handlePerson"
          :required="true"
          right-icon="arrow-right"
          :label-position="labelPosition"
        >
          <u-input
            :disabled="true"
            placeholder="请选择"
						:custom-style="pointerStyle"
            v-model="caseData.handlePerson"
            @click="()=>{if(state.canEdit) addPerson()}"
          ></u-input>
        </u-form-item>
        <u-form-item
          label="文书日期"
          label-width="200"
          right-icon="arrow-right"
          :required="true"
          ref="docDateChangeRef"
        >
          <u-input
            :disabled="true"
            placeholder="请选择日期"
            input-align="right"
            v-model="caseData.docDate"
						:custom-style="pointerStyle"
            @click="()=>{state.canEdit&&(isShowDocDate = true)}"
          />
        </u-form-item>
        <u-form-item :label-position="labelPosition" style="padding:0px;">
          <view class="desc-btm">
            本文书一式两份。一份送达移送单位，一份归档。
          </view>
        </u-form-item>
      </u-form>
      <view style="height: 30px;"></view>
    </view>
    <!-- 底部按钮开始 -->
    <view class="submit-btns btn-other-cls" v-if="state.canEdit">
      <u-button plain class="u-btn" type="primary" @click="submitBtn('save')">
        保存
      </u-button>
      <u-button class="u-btn" type="primary" @click="submitBtn('submit')">
        提交
      </u-button>
    </view>
    <!-- 底部按钮结束 -->
    <!-- 人员选择 -->
    <u-popup mode="bottom" height="80%" v-model="orgPersonSelectShow">
      <org-person-select treeType="zm-case" @choose="handlerChoosePerson"></org-person-select>
    </u-popup>
    <u-calendar :mode="mode" :max-date="yestDate" v-model="isShowDocDate" @change="changeDate('docDate',$event)">
    </u-calendar>
    <u-calendar :mode="mode" max-date="2099-12-31" v-model="isShowSeDate" @change="changeDate('sedate',$event)">
    </u-calendar>
    <!-- 时间处理 -->
    <u-picker mode="time" :params="paramsDate" v-model="isShowCaseDate" @confirm="changeTimeDate('caseDate',$event)">
    </u-picker>
    <u-popup mode="bottom" height="80%" v-model="partySelectShow">
      <select-party-component :params="partyParams" @choose="handlerChooseParty"></select-party-component>
    </u-popup>
  </view>
</template>

<script>
	import caseCommon from "../caseCommonMixin.js";
	import officeService from "@/service/case/office.service.js";
	import {
		dateUtils,
		getUpper,
		accMul,
		accDiv,
	} from "@/common/util";
	import OrgPersonSelect from "@/components/org-person-select.vue";
	import caseService from "@/service/case/case.service";
	import certificateService from "@/service/certificate/certificate.service";
	import zjCommonService from "@/service/common/common.service";
	import SelectPartyComponent from "../components/selectPartyComponent.vue";
	import {
		PARTY_TYPE_CODE,
		LOCAL_PUNISH,
		LOCAL_PAY,
	} from '@/service/case/mapping/index.js';
	import fabButton from '@/components/uni-fab.vue';

	export default {
		components: {
			OrgPersonSelect,
			SelectPartyComponent,
			fabButton
		},
		mixins: [caseCommon, ],
		data() {
			return {
				PARTY_TYPE_CODE,
				LOCAL_PUNISH,
				LOCAL_PAY,
				dicType: "",
				dicShow: false, // dic_select 是否显示
				dicKeyWords: "", // dic 关键字
				dicCurrentSelect: "", // dic 当前选择项
				mode: 'date',
				maxDate: '2099-12-31',
				yestDate: this.$u.timeFormat(Date.now()),
      isShowSeDate:false,
				isShowDocDate: false,
				importLicShow: false,
				payShow: false,
				orgPersonSelectShow: false,
				border: false,
				labelPosition: 'top',
				labelWidth: '380',
				errorType: ['border-bottom', 'message', ],
				personSelectShow: false,
				payTypeList: [{
						label: "当场收缴",
						value: "01",
					},
					{
						label: "自行缴纳",
						value: "02",
					},
				],
				PUNISH_DATA: [{
					value: '01',
					label: '警告',
				}, {
					value: '02',
					label: '罚款',
				}, ],
				rules: {
					caseProperty: [{
						required: true,
						message: '请选择案由',
						trigger: ['change', 'blur', ],
					}, ],
					handlePerson: [{
						required: true,
						message: '请选择执法人员',
						trigger: ['change', 'blur', ],
					}, ],
					legalItem: [{
						required: true,
						message: '请填写违反条例',
						trigger: 'change',
					}, ],
        defendContent: [{
          required: true,
          message: '请填写陈述、申辩',
          trigger: 'change',
        },],
        sedate: [{
          required: true,
          message: '请选择责令改正日期',
          trigger: 'change',
        },],
					punishArgument: [{
						required: true,
						message: '请填写处罚条例',
						trigger: 'change',
					}, ],
					punishItem: [{
						required: true,
						message: '请选择处罚形式',
						trigger: ['change', 'blur', ],
					}, ],
					upperMoney: [{
						required: true,
						message: '请填写罚款人民币',
						trigger: ['change', 'blur', ],
					}, ],
					docDate: [{
						required: true,
						message: '请选择文书日期',
						trigger: ['change', 'blur', ],
					}, ],
				},
				caseData: {
					caseAddr: "",
					fullDocNo: "",
					handlePerson: "",
					handlePersonUuids: "",
				}, // 处罚决定书数据
				isAction: false,
				doc: {},
				userInfo: this.$storage.get(this.$rp.common.USER).user,
				employeeLst: [],
				btnType: "",
				isShowCaseDate: false,
				partySelectShow: false,
				partyNames: '', // 当事人名称
				partyParams: {},
				isRequired: true,
				paramsDate: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true,
					timestamp: true,
				},
				partyData: {},
				fContent: [{
					iconPath: require('@/static/oview.png'),
					selectedIconPath: require('@/static/oview.png'),
					text: '预览',
					active: false,
				}],
				fContents: [{
					iconPath: require('@/static/dy.png'),
					selectedIconPath: require('@/static/dy.png'),
					text: '打印',
					active: false,
				}],
				// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx start
				pointerStyle: {
				  marginRight: "5px",
					pointerEvents: "none !important"
				},
				// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx end
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		onLoad() {
			this.caseParam = this.getRouteParam();
			!this.caseParam.docUuid && (this.caseParam.docUuid = 'simple-case-doc-01-01-01');
			console.log('====' + JSON.stringify(this.caseParam));
			if (this.caseParam.fullDocNo) {
				this.caseData.fullDocNo = this.caseParam.fullDocNo;
			}
		},
		watch: {
			isShowDocDate() {
				this.$refs.docDateChangeRef.validation();
			},
			isAction() {
				this.$refs.caseChangeRef.validation();
			},
			isShowCaseDate() {
				this.$refs.changeRefS.validation();
			},
		},
		mounted() {
			this.docStep((docInfo) => {
				this.doc = docInfo ? docInfo : {};
				this.setRightBtns();
			});
			this.initDocData();
		},
		methods: {
			// 设置右侧标题
			setRightBtns() {
				// #ifdef H5-DINGDING
				this.$deviceApi.setRight(this.state.canEdit ? '预览' : '打印', () => {
					this.printOrDown(this.state.canEdit);
					this.setRightBtns();
				}, true, true);
				// #endif
			},
			fabtrigger(btn) {
				if (btn.index == 0) {
					this.printOrDown(this.state.canEdit);
				}
			},
			// 获取涉案人list(多选)
			getPartyInfoList() {
				caseService.getPartyInfoList(this.caseParam.bizUuid).then(res => {
					if (!res.success) return;
					let names = [];
					this.partyList = res.data.length > 0 ? res.data : [];
					this.partyList.forEach(itm => {
						if (this.caseData.partyUuids.indexOf(itm.partyUuid) != -1) {
							itm.check = true;
							names.push(itm.partyName);
							this.partyData = itm;
						}
					});
					this.partyNames = names.join(',');
					this.caseData.party = this.partyNames;
					this.partyParams = {
						list: this.partyList,
						selUsersStr: this.caseData.partyUuids,
					}
				}).catch((err) => {
					this.partyList = [];
					console.log(err);
				})
			},
			// 选择当事人回调事件
			handlerChooseParty(e) {
				this.partyData = e;
				this.partySelectShow = false;
				this.partyNames = e.partyNames;
				this.caseData.party = e.partyNames;
				this.partyParams.selUsersStr = e.partyUuids;
				this.caseData.partyUuids = e.partyUuids;
			},
			// 初始化数据
			initDocData() {
				this.$u.loading('加载中...');
				officeService.docFields(this.caseParam.docUuid, true).then(docConfigs => {
					if (docConfigs.success) {
						// 获取勘验笔录信息参数
						let parms = {
							id: this.caseParam.id,
							docUuid: this.caseParam.docUuid,
							bizUuid: this.caseParam.bizUuid,
						}
						officeService.getDocPunish(parms).then(res => {
							this.$u.hideLoading();
							let [tiInfo, rs, ] = [{}, {}, ];
							if (res.success && res.data.length === 2) {
								tiInfo = res.data[0];
								rs = res.data[1];
								Object.keys(tiInfo).forEach(key => {
									rs[key] = tiInfo[key];
								});
							} else {
								rs = res.data[0];
							}
							rs.punishAmt && (rs['upperMoney'] = getUpper(rs.punishAmt));
							!rs.parentOrg && (rs.parentOrg = this.userInfo.docOrgName);
							!rs.nation && (rs['nation'] = '1');
							let psrList = this.parseEmployee(rs, 'handlePersonUuids', 'handlePerson');

							rs.payStyle && this.handleReplyData(this.payTypeList, rs.payStyle, 'payName');
							rs.punishItem && this.handleReplyData(this.PUNISH_DATA, rs.punishItem,
								'punishName');

							this.objMerge(this.caseData, rs);

							// 组装承办人数据
							if (this.caseParam['dayUuid'] && (!psrList || psrList.length == 0)) {
								certificateService.getCheckPersons(this.caseParam['dayUuid']).then(
									dper => {
										if (!dper.success) return;
										let personNames = [];
										let pUuids = [];
										let persons = dper.data.filter(_p => _p.isChecked);
										if (persons.length > 5) {
											persons = persons.slice(0, 5);
										}
										persons.forEach(p => {
											personNames.push(p.personName);
											pUuids.push(p.personUuid);
											psrList.push({
												personName: p.personName,
												leCertNo: p.certNo,
												personUuid: p.personUuid,
											})
										});
										this.caseData.handlePerson = personNames.join(",");
										this.caseData.handlePersonUuids = pUuids.join(",");
									});
							}
							this.getPartyInfoList();
						}).catch(er => {
							console.log(er);
							this.$u.hideLoading();
							this.$u.toast(er);
						});
					} else {
						this.$u.toast(docConfigs.msg);
					}
				}).catch(er => {
					console.log(er);
					this.$u.hideLoading();
					this.$u.toast(er);
				});
			},
			// 回显数据
			handleReplyData(list, val, field) {
				let filterData = list.filter(item => item.value == val);
				this.$set(this.caseData, field, filterData[0].label);
			},
			// 当处罚比例大于100%时将比例重置为100%
			changedRate(e) {
				console.log(e, '1111');
				if (e > 100) {
					this.caseData.rate = 100;
				}
			},
			// 自动计算处罚金额并且 转换大写
			changeUpperNumber() {
				let az = 0;
				let rate = 0;
				try {
					az = Number(this.caseData.localCaseTotalVal);
					if (isNaN(az)) az = 0;
					rate = Number(this.caseData.rate);
					if (isNaN(rate)) rate = 0;
					if (rate > 100) rate = 100;
				} catch (e) {
					az = 0;
					rate = 0;
				}
				if (az == 0 || rate == 0) {
					this.caseData.punishAmt = "";
				} else {
					//  保留2位并且四舍五入 fsx 2024-1-18 开始
					let value = accMul(az, rate)
					value =  Math.round(Number(accDiv(Number(value), 100)) * 100) / 100 ;
					//  保留2位并且四舍五入 fsx 2024-1-18 结束

					this.caseData.punishAmt = value;
				}
				this.caseData.punishAmt && this.$set(this.caseData, 'upperMoney', getUpper(this.caseData.punishAmt));
			},
			// 选择案由返回的数据
			updateBackState(param) {
				// 案由
				if (param.caseSelectionData) {
					let [names, ids, legas, punish, ] = [
						[],
						[],
						[],
						[],
					];
					param.caseSelectionData.forEach((item) => {
						names.push(item.caseProperty);
						ids.push(item.casepropUuid);
						legas.push(item.legalItem);
						punish.push(item.punishItem);
					});
					this.$set(this.caseData, 'caseProperty', names.join(","));
					this.$set(this.caseData, 'casePropUuids', ids.join(","));
					this.$set(this.caseData, 'punishArgument', punish.join(";"));
					this.$set(this.caseData, 'legalItem', legas.join(";"));
					this.isAction = false;
				}
			},
			// 下拉框选择
			selectConfirm(type, name, e) {
				this.caseData[name] = '';
				this.caseData[type] = '';
				e.map((val, index) => {
					this.caseData[type] = val.value;
					this.caseData[name] = val.label;
				});
				this.$refs.punishRefs.validation();
				// 清空数据
				if (this.caseData.punishItem == this.PUNISH_DATA[0].value) {
					this.caseData.punishAmt = '';
					this.caseData.upperMoney = '';
				}
			},
			changeDate(type, e) {
				this.caseData[type] = dateUtils.dateFormat("yyyy年MM月dd日", new Date(e.result));
				this.$refs.docDateChangeRef.validation();
			},
			changeTimeDate(type, e) {
				this.caseData[type] = this.$u.date(e.timestamp, 'yyyy年mm月dd日 hh时MM分');
			},
			radioGroupChange(e) {
				this.caseData.payStyle = e;
			},
			// 添加执法人员事件
			addPerson() {
				this.orgPersonSelectShow = true
			},
			handlerChoosePerson(psrList) {
				let names = [];
				let ids = [];
				psrList.forEach(p => {
					names.push(p.name);
					ids.push(p.id);
				});
				this.$set(this.caseData, 'handlePerson', names.join(","));
				this.$set(this.caseData, 'handlePersonUuids', ids.join(","));
				this.orgPersonSelectShow = false;
			},

			// 提交保存
			submitBtn(type) {
				if (type == 'preview') {
					if (!this.doc.isRecorded) {
						this.$u.toast('请先保存数据');
						return;
					}
					officeService.buildLocalPunish("/punish/doc-locale-punish", this.doc.docInsUuid).then(pdfId => {
						if (pdfId.success) {
							this.downloadFile(pdfId.bean, "预览", false);
						} else {
							this.$u.toast(pdfId.msg);
						}
					});
				} else {
					let flag = this.validForm(type);
					if (flag) {
						this.handleOperBtn(type);
					}
				}
			},
			handleOperBtn(flag) {
				if (this.partyData.partyType == PARTY_TYPE_CODE.personal) {
					if (Number(this.caseData.punishAmt) > 200) {
						this.$u.toast("个人罚款金额不能超过200元!");
						return;
					}
				} else {
					if (Number(this.caseData.punishAmt) > 3000) {
						this.$u.toast("企业罚款金额不能超过3000元!");
						return;
					}
				}
				let [docGoodsReg, self, ] = [this.caseData, this, ];
				let {
					titemUuid,
					docUuid,
					id,
					type,
					bizUuid,
					caseCode,
					caseType,
				} = this.caseParam;
				this.caseParam.caseUuid && (docGoodsReg['caseUuid'] = this.caseParam.caseUuid);
				flag === 'save' && (this.$u.loading('数据保存中...'));
				officeService.saveDocPunish(docGoodsReg, docUuid, titemUuid, id, type).then((res) => {
					this.$u.hideLoading();
					if (res.success) {
						let bean = res.bean;
						this.caseParam.bizUuid = bean.caseUuid;
						this.caseParam.caseUuid = bean.caseUuid;
						// bizUuid = bean.caseUuid;

						docGoodsReg.localePunishUuid = bean.localePunishUuid;
						let saveData = res.data[0];
						self.doc['isRecorded'] = saveData.isRecorded;
						self.doc['docInsUuid'] = saveData.docInsUuid;
						this.caseParam.id = saveData.docInsUuid;
						docGoodsReg['fullDocNo'] = saveData.docCodeTitle;
						this.docIns = docGoodsReg;
						this.caseData = docGoodsReg;
						if (flag === 'submit') {
							this.$u.loading('数据提交中...');
							officeService.submitDocPunish(bean, docUuid, titemUuid, bean.localePunishUuid, type)
								.then(res => {
									this.$u.hideLoading();
									this.saveBehaviorLog(1, this.caseParam, this.doc);
									if (res.success) {
										// 返回列表
										this.$u.toast(res.msg);
										self.backPrev({
											paramKey: "offiList",
											param: {
												caseUuid: bizUuid,
												caseCode: caseCode,
												caseType: caseType,
											},
										});
									} else {
										this.$u.toast(res.msg);
									}
								}).catch(er => {
									console.log(er);
									this.$u.hideLoading();
									this.$u.toast(er);
								});
						} else {
							this.$u.toast(res.msg);
							this.saveBehaviorLog(0, this.caseParam, this.doc);
						}
					} else {
						this.$u.toast(res.msg);
					}
				});
			},
			// 打印/预览
			printOrDown(flag) {
				if (flag) {
					// 调接口预览
					this.submitBtn('preview');
				} else {
					this.downloadFile(this.doc.pdfFileId);
				}
			},
			downloadFile(fileId, titleName, isDownload) {
				let pdfIds = fileId;
				if (!pdfIds) {
					this.$u.toast("没有文书");
					return;
				}
				this.setRouteParam({
					fileId: pdfIds,
					fileName: titleName,
					isDownload: isDownload,
				});
				this.$u.route('pages/commonPage/printerComponent');
			},
			// 表单验证
			validForm(type) {
				let basicValid = false;
				this.btnType = type;
				this.$refs.uForm.validate(valid => {
					if (valid) {
						if (!this.caseData.partyUuids) {
							this.$u.toast('请选择当事人!');
							return;
						}
						// 罚款
						if (this.caseData.punishItem == LOCAL_PUNISH.FINE) {
							if (!this.caseData.punishAmt) {
								this.$u.toast('请输入罚款人民币');
								return;
							}
							if (this.caseData.payStyle == null) {
								this.$u.toast('请选择缴款方式');
								return;
							}
						}
						basicValid = true;
					} else {
						basicValid = false;
					}
				});
				return basicValid;
			},
		},
	}
</script>

<style lang="scss" scoped>
	@import "../case_common.scss";

	.page {
		padding: 0;
	}

	.doc-no {
		display: inline-flex;
		height: 35px;
		width: 60px;
		text-align: center !important;
		flex: none;
	}

	.input-text {
		display: inline-flex;
		width: 100%;
		flex: none;
	}
</style>
